package com.laolang.ssh.config;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Import;
import org.springframework.transaction.annotation.EnableTransactionManagement;
import org.springframework.web.servlet.HandlerMapping;
import org.springframework.web.servlet.ViewResolver;
import org.springframework.web.servlet.config.annotation.EnableWebMvc;
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurationSupport;
import org.springframework.web.servlet.view.InternalResourceViewResolver;

/**
 * spring mvc 配置类
 * 
 * @author 小代码
 * @version 1.0
 *
 */
@Configuration
@Import(DataSourceConfig.class)
@EnableWebMvc
@EnableTransactionManagement
@ComponentScan("com.laolang.ssh.*")
public class MyMvcConfig extends WebMvcConfigurationSupport {

	/**
	 * 视图处理器
	 * 
	 */
	@Bean
	public ViewResolver viewResolver() {
		InternalResourceViewResolver viewResolver = new InternalResourceViewResolver();
		viewResolver.setPrefix("/WEB-INF/views/");
		viewResolver.setSuffix(".jsp");
		return viewResolver;
	}
	
	@Bean
	public HandlerMapping resourceHandlerMapping() {
    	return super.resourceHandlerMapping();
    }

	/**
	 * 资源访问处理器
	 */
	@Override
	protected void addResourceHandlers(ResourceHandlerRegistry registry) {
		registry.addResourceHandler("/assets/**").addResourceLocations("/assets/");
	}
	
	
}
